package news.util;

import news.example.News;

import java.util.List;

/**
 * @author Administrator
 * 分页对象
 */
public class PageBean {

    private int currPageNo = 1;
    private int pageSize = 10;
    private int totalCount = 1;
    private int totalPageCount = 1;
    private int start;
    private int pageIndex=1;
    List<News> objectList;

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getCurrPageNo() {
        return currPageNo;
    }

    public void setCurrPageNo(int currPageNo) {
        this.currPageNo = currPageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;

        initTotalPageCount();

        initStart();

    }

    public void initTotalPageCount(){
        if (this.totalCount>0){
            this.totalPageCount = (this.totalCount % this.pageSize == 0) ?
                    (this.totalCount / this.pageSize):
                    ((this.totalCount / this.pageSize)+1);
        }
    }

    public void initStart(){
        this.start = (this.currPageNo - 1) * this.pageSize;
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<News> getObjectList() {
        return objectList;
    }

    public void setObjectList(List<News> objectList) {
        this.objectList = objectList;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
}
